<template>
    <div class="dahezi">
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item >🏠</el-breadcrumb-item>
            <el-breadcrumb-item>搜索</el-breadcrumb-item>
        </el-breadcrumb>
        <div class="hezi">
            <div class="hezi2">
                <div class="hezi3">
                    <div class="sousuolang1">
                        <el-button  @click="sousuowengzhang" type="success" >文章</el-button>
                        <el-button @click="sousuotiezis" type="success" >帖子</el-button>
                            <el-button @click="sousuoyinshi" type="success" >饮食</el-button>
                    </div>
                    <div v-show="tiezikaiguan">
                        <Sousuotiezi ref="sousuotiezi" :content="content">
                        </Sousuotiezi>
                    </div>
                    <div v-show="flag">
                        <Sousuowenzhang ref="sousuowenzhang" :content="content">
                        </Sousuowenzhang>
                    </div>
                    <div v-show="yinshikaiguan">
                        <Sousuoyinshi ref="sousuoyinshi" :content="content">
                        </Sousuoyinshi>
                    </div>
                    </div>
            </div>
        </div>
    </div>
</template>

<script>
    import Sousuowenzhang from "./suosuowengzhang.vue";
    import Sousuotiezi from "./sousuotiezi.vue";
    import Sousuoyinshi from "./sousuoyinshi.vue";
    // import Editor from '@/components/Editor';
    export default {
        name: "sousuo",
        components: {
            // Editor ,
            Sousuowenzhang,
            Sousuotiezi,
            Sousuoyinshi,
        },
        data(){
            return{
                flag: true,
                tiezikaiguan:false,
                content: '',
                yinshikaiguan: false,
            }
        },
        created() {
            this.sousuo();
            this.sousuowengzhang();
            // this.getuserlll();
        },
        methods: {
            refreshChildYinShi() {
                this.$refs.sousuoyinshi.getList()
            },
            refreshChildWenZhang() {
                this.$refs.sousuowenzhang.chaxunwenzhan()
            },
            refreshChildTieZi() {
                this.$refs.sousuotiezi.chaxuntiezi()
            },
            async getuserlll(){
                const {data:jieguo}=await this.$http.get('user/info',{headers:{
                        'Authorization':window.sessionStorage.getItem('token')
                    }})
                jieguo.data.basicUserInformation.id
                this.shiyisheng=jieguo.data.userRole
                this.wenform.userName=jieguo.data.basicUserInformation.username
                this.tieform.userId=jieguo.data.basicUserInformation.id
                this.basicUserInformation=jieguo.data.basicUserInformation
            },
            async sousuo() {
                this.content = this.$route.query.resouciyu;
                this.sousuowengzhang();
            },
            async sousuowengzhang(){
                this.yinshikaiguan=false;
                this.tiezikaiguan=false;
                this.flag = true ;
                this.refreshChildWenZhang();
            },
            async sousuotiezis(){
                this.yinshikaiguan=false;
                this.tiezikaiguan=true;
                this.flag = false ;
                this.refreshChildTieZi();
            },
            async sousuoyinshi(){
                this.yinshikaiguan=true;
                this.flag=false;
                this.tiezikaiguan=false;
                this.refreshChildYinShi();
            },
        },
        mounted() {
            this.sousuo();
        },
        // 如果不用watch进行监听，则会出现参数只获取一次的情况
        watch: {
            '$route'(){
                this.sousuo();
            }
        },
    }
</script>

<style scoped>

    .hezi{
        width: 80%;
        min-height: 900px;
        height: auto!important;
        display: flex;
        justify-content:center;
        align-items:center;
    }
    .hezi2{
        width: 100%;
        background-color: white;
        min-height: 850px;
        height: auto!important;
        margin-top: 3px;
        /*display: flex;*/
    }
    .hezi3{
        width: 100%;
    }

    .dahezi{
        padding-top: 3px;
        background-color: #fffacd;
        min-height: 1000px;
        height: auto!important;
    }
 .sousuolang1{
     width: 100%;
     height:40px;
     background-color: #FFFACD;
     display: flex;
 }
 .wenzhanganniu{
     width: 70px;
     height:40px;
     background-color: #409EFF;
 }
 .tiezianniu{
     width: 70px;
     height:40px;
     background-color: #FFFACD;
 }

    #rcorners1 {
        border-radius: 100px;
        background: white;
        padding: 20px;
        width: 75px;
        height: 0px;
        float: right;
        text-align: center;
        color: black;
        font-size: 18px;
        border: #EAEDF1 solid 1px;
    }
    .yierhang1{
        width: 800px;
        height: 100px;
        text-align: center;
        margin-left: 150px;
        margin-right: 10px;
        margin-top: 20px;
        /*background: #FFFFE0;*/
        /*border: #FFFACD solid 2px;*/
    }
    .jinrirediang11{
        height: 150px;
        width: 40%;
        margin-bottom:25px;
    }
    .tishi{
        width: 100%;
        height: 50px;
        color: #888888;
        font-size: 30px;
        text-align: center;
    }
</style>
